rm(list=ls())
setwd("D:/Dropbox/Grad School Year 3 Term 1/Time Series/TS Project")
load("Time_Series-Original.RData")

start <- as.Date("2015-06-01")

######### 2016 ###########
xlabels <- c("June 1st", "July 1st", "Aug 1st",  "Sept 1st", "Oct 1st","Nov 1st", "Dec 1st", "Jan 1st", "Feb 1st")
xlab.at <- c(0, 31, 62, 93, 123, 154, 184, 215, 246)
rep.debate <- c("2015-08-06", "2015-09-16", "2015-10-28", "2015-11-10", "2015-12-15",
                "2016-01-14", "2016-01-28")
rep.debate <- as.Date(rep.debate)
rep.debate.time <- as.numeric(rep.debate - as.Date(start))+1

pdf("Ted_Cruz_Plots.pdf", height=12, width=7)
# png("Ted_Cruz_Plots.png", height=800, width=600)

par(mfrow=c(3,1), mar=c(1,4,0,0), oma=c(4,0,3,1),cex=1.1, cex.lab=1.25, cex.main=1.25)
plot.new()
plot.window(ylim=c(0,100), xlim=c(0,250))
lines(c(cruz[,1]), lwd=2)
title(ylab="Media")
axis(2, at=c(0, 20, 40, 60, 80, 100))
box()
abline(v=rep.debate.time, lty=2)

plot.new()
plot.window(ylim=c(0,100), xlim=c(0,250))
lines(c(cruz[,2]), lwd=2)
title(ylab="Interest")
axis(2, at=c(0, 20,40, 60, 80, 100))
box()
abline(v=rep.debate.time, lty=2)

plot.new()
plot.window(ylim=c(0,100), xlim=c(0,250))
lines(c(cruz[,3]), lwd=2)
title(ylab="Support")
axis(1, at=xlab.at, labels=xlabels)
axis(2, at=c(0, 20, 40,60, 80, 100))
box()
abline(v=rep.debate.time, lty=2)
title(main="Ted Cruz",xlab="Days", outer=T)
dev.off()


pdf("Donald_Trump_Plots.pdf", height=12, width=7)
# png("Donald_Trump_Plots.png", height=800, width=600)

par(mfrow=c(3,1), mar=c(1,4,0,0), oma=c(4,0,3,1),cex=1.1, cex.lab=1.25, cex.main=1.25)
plot.new()
plot.window(ylim=c(0,100), xlim=c(0,250))
lines(c(trump[,1]), lwd=2)
title(ylab="Media")
axis(2, at=c(0, 20, 40, 60, 80, 100))
box()
abline(v=rep.debate.time, lty=2)

plot.new()
plot.window(ylim=c(0,100), xlim=c(0,250))
lines(c(trump[,2]), lwd=2)
title(ylab="Interest")
axis(2, at=c(0, 20,40, 60, 80, 100))
box()
abline(v=rep.debate.time, lty=2)

plot.new()
plot.window(ylim=c(0,100), xlim=c(0,250))
lines(c(trump[,3]), lwd=2)
title(ylab="Support")
axis(1, at=xlab.at, labels=xlabels)
axis(2, at=c(0, 20, 40,60, 80, 100))
box()
abline(v=rep.debate.time, lty=2)
title(main="Donald Trump",xlab="Days", outer=T)
dev.off()

